package com.sixmac.service.impl;

import com.sixmac.core.base.service.BaseService;
import com.sixmac.core.plugins.dao.Md;
import com.sixmac.core.toolbox.CMap;
import com.sixmac.core.toolbox.support.Convert;
import com.sixmac.model.CourseChapter;
import com.sixmac.service.CourseService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * CourseServiceImpl
 * 2018-07-03 17:19:48
 *
 * @author Blade
 */
@Service
public class CourseServiceImpl extends BaseService<CourseChapter> implements CourseService {

    @Override
    public boolean updateStatus(String ids, Integer status) {
        CMap map = CMap.init().set("status", status).set("ids", Convert.toIntArray(ids));
        boolean temp = updateBy("status = #{status}", "id in (#{join(ids)})", map);
        return temp;
    }

    @Override
    @SuppressWarnings("unchecked")
    public Map<String, Object> findOne(Object id) {
        return Md.selectOne("course.findOne", CMap.init().set("id", id), Map.class);
    }

}
